#include <iostream>
#include <cstdio>

using namespace std;

#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1

const int maxn = 200020;

int n;

int sum[maxn << 2];
int pos[maxn], val[maxn];

void PushUp(int rt) {
	sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
}

void build(int l, int r, int rt) {
	if (l == r) {
		sum[rt] = 1;
		return;
	}
	int m = (l + r) >> 1;
	build(lson);
	build(rson);
	PushUp(rt);
}

int query(int pos, int l, int r, int rt) {
	sum[rt]--;
	if (l == r) return l;
	int m = (l + r) >> 1;

	if (sum[rt << 1] < pos) {
		return query(pos - sum[rt << 1], rson);
	} else {
		return query(pos, lson);
	}
}


int main() {
	while(scanf("%d", &n) != EOF) {
		build(1, n, 1);
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &pos[i], &val[i]);
		}

		int ans[maxn], res[maxn];
		for (int i = n - 1; i >= 0; i--) {
			res[query(pos[i] + 1, 1, n, 1)] = val[i];
		}

		for (int i = 1; i <= n; i++) {
			printf("%d%c", res[i], i != n  ? ' ' : '\n');
		}
	}
}